﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;

namespace WindowsFormsApplication2.FORMS
{
    public partial class frmTailanProduct : Form
    {
        static string fname;
        public frmTailanProduct(string name)
        {
            InitializeComponent();
            fname = name;
        }

        private void frmTailanProduct_Load(object sender, EventArgs e)
        {
            crystalReportViewerPro.RefreshReport();
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load("D:\\Диплом\\New folder\\WindowsFormsApplication2\\WindowsFormsApplication2\\All FORMS\\Report forms\\Report\\CrystalReportPro.rpt");

            ParameterFieldDefinitions crParameterFieldDefinitions;
            ParameterFieldDefinition crParameterFieldDefinition;

            ParameterValues crParameterValues = new ParameterValues();
            ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

            crParameterDiscreteValue.Value = fname;
            crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
            crParameterFieldDefinition = crParameterFieldDefinitions["name"];
            crParameterValues = crParameterFieldDefinition.CurrentValues;

            crParameterValues.Clear();
            crParameterValues.Add(crParameterDiscreteValue);
            crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

            
            crystalReportViewerPro.ReportSource = cryRpt;
            crystalReportViewerPro.Refresh();
        }
    }
}
